import pytest
from utils.RequestHandler import Request
from utils.YamlHandler import yamler
from utils.LogHandler import logger
from conf import settings

yaml_data = yamler.read_yaml(r"D:\Coding\API_Test_Frame2\data\login.yaml")


@pytest.fixture(scope='class', autouse=True)
def jwt_token():
    logger.info("获取token")
    res = Request().send(**yaml_data)
    print(res)
    token = res.json().get("data", None).get("token", None)
    print("++++++++++", token)
    content = {"token": "Bearer " + token}
    logger.info("将token写入文件")
    yamler.write_yaml(settings.TOKEN_FILE_PATH, content)
